
$(function () {
    var goods_order_id = parseInt(GetQueryString('goods_order_id'));
    var html_data = {
        baseConfig: baseConfig,
        sessionid: '',
        sessionid_q: '',
        address_info:{},
        province_list:[],
        city_list:[],
        start_list:[{type:1, index:0},{type:1, index:1},{type:1, index:2},{type:1, index:3},{type:1, index:4}],
        goods_order_item: []

    };
    var app = new Vue({
        el: '#address_modefy',
        data: html_data,
        methods: {
            price_filter: price_filter,

            dafen: function (item, index) {

                item.pingfen = index;
                for(var i=0;i<5;i++){
                    if(i<=index){
                        $("#star_"+item.id+"_"+i).attr("src", 'img2/star_big_light.png')
                    }else{
                        $("#star_"+item.id+"_"+i).attr("src", 'img2/star_big_normal.png')
                    }

                }

            },
            save_comment:function(){
                var is_ok = true;
                var data = [];
                _(html_data.goods_order_item).each(function (item) {
                    data.push({goods_id:item.goods_id, value:item.pingfen, content:item.pingjia});
                })
                if(!is_ok){
                    return;
                }

                api.lgc.create_multi_goods_order_comment({goods_order_id:goods_order_id, data:JSON.stringify(data)}).then(function (value) {
                    if(value.success){
                        Magiclamp.mcAlert("提示", "评价成功。", null, function () {

                        });
                    }
                })

            },
            page_back: function () {
                baseConfig.page_back();
            }
        }
    });

    html_data.sessionid = GetQueryString('sessionid');
    if (html_data.sessionid) {
        html_data.sessionid_q = "sessionid=" + html_data.sessionid;
        client_storage('sessionid', html_data.sessionid);
    }


    if(goods_order_id){
        api.lgc.get_goods_order_comment({goods_order_id: GetQueryString("goods_order_id")}).then(function (data) {

            html_data.orderinfo = data.result.goods_order;
            html_data.goods_order_item = data.result.gooods_order_item;
            // _(html_data.goods_order_item).each(function (item) {
            //     item.pingfen = 4;
            //     item.pingjia = "商品满意，快递给力，下回还买。";
            // })
        });
    }


});
